using Windows.UI.Xaml.Controls;

namespace Ebt.Mvvm
{
    /// <summary>
    /// Allows a view model handle navigation events.
    /// Implement this interface in view models that is assigned to a <see cref="Page.DataContext"/>.
    /// </summary>
    public interface IPageModel
    {
        /// <summary>
        /// Notifies the page model before leaving the page. Allows to cancel the navigation.
        /// </summary>
        /// <param name="cancel">Set it to <c>true</c> to cancel the navigation from this page.</param>
        void OnNavigatingFrom(ref bool cancel);

        /// <summary>
        /// Notifies the page model about leaving the page.
        /// </summary>
        /// <param name="navigationArgs">Contains parameters.</param>
        void OnNavigatedFrom(NavigationArgs navigationArgs);

        /// <summary>
        /// Notifies the page model about opening the page.
        /// </summary>
        /// <param name="navigationArgs">Contains parameters.</param>
        void OnNavigatedTo(NavigationArgs navigationArgs);

        /// <summary>
        /// Gets the value indicating whether the page is active now.
        /// Do not change it directly.
        /// </summary>
        /// <value>
        /// <c>True</c> between <see cref="OnNavigatedTo"/> and <see cref="OnNavigatingFrom"/> calls and during them.
        /// If navigation is canceled then it does not change.
        /// </value>
        bool IsPageActive { get; set; }
    }
}